<template>
     <div>
         <input type="text" v-model="ipt" @input="search1fn"> 
         <ul v-if="filterend.length">
                <p v-for="(item,index) in filterend" :key="index">
                    {{item}}
                </p>
         </ul>
         <ul v-else>
             <img src="https://www.baidu.com/img/flexible/logo/pc/result.png" alt="">
         </ul>
     </div>
</template>

<script>
import {throttling} from "../utils/throttling"
import {mapState,mapMutations} from "vuex"
export default {
    data() {
        return {
            ipt:"",
            timmmer:null
        }
    },
    computed:{
       ...mapState(["filterarr",'filterend'])
    },
    mounted(){
        console.log( throttling);
      
    },
    methods:{
         ...mapMutations(["filterdata"]),
         searchfn() { // 一按键盘就清理了延时器 // 手写节流

             clearTimeout(this.timmmer)
             this.timmer = setTimeout(()=>{
                
                 
             },2000) 
         },
         search1fn:throttling(2000,function(){
                  this.filterdata(this.ipt)
         })
    }
}
</script>

<style>

</style>